package cn.humaohua.study.yanmo_design_pattern.ch14.v3;

import cn.humaohua.study.yanmo_design_pattern.ch14.v1.Aggregate;
import cn.humaohua.study.yanmo_design_pattern.ch14.v1.Iterator;
import cn.humaohua.study.yanmo_design_pattern.ch14.v2.PayModel;

import java.util.ArrayList;
import java.util.List;

public class PayManager extends Aggregate {
    private List list = new ArrayList();

    public List getPayList() {
        return list;
    }

    public void calcPay() {
        PayModel pm1 = new PayModel();
        pm1.setPay(3800);
        pm1.setUserName("zhang3");

        PayModel pm2 = new PayModel();
        pm2.setPay(5800);
        pm2.setUserName("li4");

        list.add(pm1);
        list.add(pm2);

    }

    public Object get(int index) {
        if (index < this.list.size())
            return list.get(index);
        return null;
    }

    public int size() {
        return list.size();
    }

    @Override
    public Iterator createIterator() {
        return new CollectionIteratorImpl(this);
    }
}